<template>
  <el-pagination
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :current-page="queryParams.pagenum"
    :page-sizes="pageSizes"
    :page-size="queryParams.pagesize"
    layout="total, sizes, prev, pager, next, jumper"
    :total="total"
    class="pagination"
  >
  </el-pagination>
</template>
<script>
export default {
  name: 'page',
  props: {
    // 外界（父级）传过来的参数
    queryParams: {
      // 当前默认显示的条数，和当前页数
      type: Object,
      required: true
    },
    total: {
      type: Number,
      required: true
    },
    // 下拉默认是 [1, 3, 5, 10]
    pageSizes: {
      default: () => [1, 2, 5, 10]
    }
  },
  methods: {
    // 往外界（父级）传递的数据
    handleSizeChange(size) {
      // size 显示的条数，多少页每页
      this.$emit('size-change', size)
    },
    handleCurrentChange(pagenum) {
      // 显示的页数，当前多少页
      this.$emit('current-change', pagenum)
    }
  }
}
</script>
